#include <iostream>
#include <string>
#include <deque>

using namespace std;

int main() {
    string input;
    deque<char> result;
    auto cursor = result.begin();

    // 读取输入
    getline(cin, input);

    // 处理每个输入字符
    for (char c : input) {
        if (c == '[') {
            cursor = result.begin();
        } else if (c == ']') {
            cursor = result.end();
        } else {
            cursor = result.insert(cursor, c);
            ++cursor;
        }
    }

    // 将结果转换为string并输出
    cout << string(result.begin(), result.end()) << endl;

    return 0;
}
